﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddContract.aspx.cs" Inherits="Operator_AddContract"
    MasterPageFile="~/Site.master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <br />
    <asp:HyperLink ID="OperatorsLink" runat="server" NavigateUrl="~/Operator/OperatorPanel.aspx">Панель оперетора</asp:HyperLink>&nbsp;→&nbsp;<asp:HyperLink
        ID="HyperLink1" runat="server" NavigateUrl="~/Operator/ApprovedRequests.aspx">Заявки на оформление контрактов</asp:HyperLink>&nbsp;→&nbsp;<asp:Label
            ID="Label1" runat="server" Text="Оформление контракта" Font-Bold="true"></asp:Label>
    <br />
    <br />
    <table>
        <tr>
            <td>
                <asp:Label ID="CreditLabel" runat="server" Text="Кредит:" AssociatedControlID="CreditList"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="CreditList" runat="server" DataSourceID="SqlDataSourceCredit"
                    DataTextField="Name" DataValueField="CreditID" OnDataBound="CreditList_DataBound">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceCredit" runat="server" ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>"
                    SelectCommand="SELECT [Name], [CreditID] FROM [Credit] WHERE ([Active] = @Active)">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="true" Name="Active" Type="Boolean" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="TermLabel" runat="server" Text="На срок:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="TermLength" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="AmountLabel" runat="server" Text="Сумма:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="Amount" runat="server"></asp:TextBox><br />
                <asp:DropDownList ID="CurrencyList" runat="server" DataSourceID="SqlDataSourceCurrency"
                    DataTextField="Name" DataValueField="CurrencyID" OnDataBound="CurrencyList_DataBound">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceCurrency" runat="server" ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>"
                    SelectCommand="SELECT [CurrencyID], [Name] FROM [Currency]"></asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="FormLabel" runat="server" Text="Форма выдачи:"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="CreditFacilitiesFormList" runat="server" DataSourceID="SqlDataSourceForm"
                    DataTextField="Name" DataValueField="CreditFacilitiesFormId" Enabled="false">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceForm" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
                    SelectCommand="SELECT CreditFacilitiesForm.CreditFacilitiesFormId, CreditFacilitiesForm.Name FROM CreditFacilitiesForm INNER JOIN CreditCreditFacilitiesForm ON CreditFacilitiesForm.CreditFacilitiesFormId = CreditCreditFacilitiesForm.CreditFacilitiesFormId INNER JOIN Credit ON CreditCreditFacilitiesForm.CreditId = Credit.CreditID INNER JOIN CreditRequest ON CreditFacilitiesForm.CreditFacilitiesFormId = CreditRequest.CreditFacilitiesFormId AND Credit.CreditID = CreditRequest.CreditId WHERE (CreditRequest.CreditRequestId = @requestId)">
                    <SelectParameters>
                        <asp:SessionParameter Name="requestId" SessionField="requestId" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
            <td>
                <asp:Button ID="OpenNeedBankAccountButton" runat="server" Text="Открыть счёт" Visible="false"
                    OnClick="OpenNeedBankAccountButton_Click" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="CompanyNameLabel" runat="server" Text="Название предприятия"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyName" runat="server"></asp:TextBox>
                <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="CompanyName"
                    MinimumPrefixLength="1" CompletionInterval="10" CompletionSetCount="3" UseContextKey="True"
                    ServiceMethod="GetCompletionList" DelimiterCharacters="" Enabled="True" ServicePath="">
                </asp:AutoCompleteExtender>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="HeadNameLabel" runat="server" Text="Ф.И.О. руководителя"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="HeadName" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="BankAccountNumberLabel" runat="server" Text="Номер счёта для перевода"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="BankAccountNumber" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>
    <br />
    <asp:Button ID="AddContractButton" runat="server" Text="Оформить контракт" OnClick="AddContractButton_Click" Enabled="false" />
    <asp:Button ID="PrintButton" runat="server" Text="Распечатать контракт" 
        onclick="PrintButton_Click" />
    <br />
    <asp:Button ID="RejectButton" runat="server" Text="Отказать" OnClick="RejectButton_Click" />
    <asp:Label ID="ErrorLabel" runat="server" Text=""></asp:Label>
</asp:Content>
